/*
 * Copyright 2010 - Jeremie Brebec
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package org.jb.coinche.client.business.model;

import java.io.Serializable;

/**
 * 
 * @author jeremie
 *
 */
public class Card implements Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 591936618938681258L;
	/**
	 * 
	 * @author jeremie
	 *
	 */
	public enum Suit {
		CLUBS,
		DIAMONDS,
		SPADES,
		HEARTS;

		// TODO : Externaliser la localisation
		public String toText() {
			switch( this ) {
			case CLUBS: return "Trèfles";
			case DIAMONDS: return "Carreaux";
			case HEARTS: return "Coeurs";
			case SPADES: return "Piques";
			default:
				return "";
			}
		}
	}
	
	/**
	 * 
	 * @author jeremie
	 *
	 */
	public enum Rank {
		KING,
		QUEEN,
		JACK,
		TEN,
		NINE,
		EIGHT,
		SEVEN,
		AS
	}
	
	/*
	 * 
	 */
	public Card() {
		this.suit = null;
		this.rank = null;
	}
	
	/*
	 * 
	 */
	public Card(Suit color, Rank value) {
		this.suit = color;
		this.rank = value;
	}

	/**
	 * 
	 * @return
	 */
	public Suit getSuit() {
		return suit;
	}
	
	/**
	 * 
	 * @param color
	 */
	public void setSuit( Suit color ) {
		this.suit = color;
	}
	
	/**
	 * 
	 * @return
	 */
	public Rank getValue() {
		return rank;
	}
	
	/**
	 * 
	 * @param value
	 */
	public void setValue( Rank value ) {
		this.rank = value;
	}
	
	
	/*
	 * (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (obj instanceof Card) {
			Card c = (Card)obj;
			return suit.equals( c.getSuit() ) && rank.equals( c.getValue() );
		}
		return false;
	}

	/*
	 * (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append( rank );
		sb.append( '@' );
		sb.append( suit );
		return sb.toString();
	}



	private Suit suit;
	private Rank rank;
}
